<template>
  <PageContainer>
    <el-table :data="tableData">
      <el-table-column prop="name" label="姓名" />
      <el-table-column prop="name" label="手机号" />
      <el-table-column label="操作" align="right">
        <template #default="scope">
          <el-link type="primary" :underline="false" @click="changePassword(scope.row)">修改密码</el-link>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="修改密码" v-model="changePasswordVisible" width="450px">
      <el-form :model="changePasswordForm" label-width="auto">
        <el-form-item label="手机号">
          <span>{{ curRow.mobile }}</span>
        </el-form-item>
        <el-form-item label="验证码">
          <el-input v-model="changePasswordForm.oldPassword" class="!w-[220px]" placeholder="请输入旧密码" />
          <el-button link @click="sendSmsCode" class="ml-[10px]">获取验证码</el-button>
        </el-form-item>
        <el-form-item label="旧密码">
          <el-input v-model="changePasswordForm.oldPassword" class="!w-[220px]" placeholder="请输入旧密码" />
        </el-form-item>
        <el-form-item label="新密码">
          <el-input v-model="changePasswordForm.newPassword" class="!w-[220px]" placeholder="请输入新密码" />
        </el-form-item>
        <el-form-item label="确认密码" style="margin: 0">
          <el-input
            v-model="changePasswordForm.newPasswordAgain"
            class="!w-[220px]"
            placeholder="请输入再次输入新密码"
          />
        </el-form-item>
        <el-form-item label="  " style="margin: 0">
          <span class="color-999 text-[12px]">密码必须是8-16位的英文字母、数组、字符组合</span>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="center">
          <el-button type="primary" @click="changePasswordVisible = false">立即验证</el-button>
        </div>
      </template>
    </el-dialog>
  </PageContainer>
</template>

<script lang="ts" setup>
interface TableDataItem {
  mobile: string
  name: string
}

const tableData = ref<Array<TableDataItem>>([
  {
    name: '王小虎',
    mobile: '12345678901',
  },
])
const curRow = ref<TableDataItem>({
  name: '',
  mobile: '',
})
const changePasswordVisible = ref(false)
const changePasswordForm = reactive({
  oldPassword: '',
  newPassword: '',
  newPasswordAgain: '',
})
const sendSmsCode = () => {
  console.log('发送验证码')
}
const changePassword = (row: TableDataItem) => {
  curRow.value = row
  changePasswordVisible.value = true
  console.log('修改密码')
}
</script>

<style scoped lang="scss"></style>
